import * as types from './mutations_types'

module.exports = {
    //设置展示的用户的数据
    [types.SET_USERS_DATA](state, {
        data
    }) {
        state.tableData = data.lit;
        state.tableTotal = data.count;
        // console.log(state.tableData);
    },
    //删除用户数据
    [types.DELETE_TABLE_USER](state, {
        deleteIndex
    }) {
        console.log(state.tableData);
        state.tableData.splice(deleteIndex, 1);
        console.log(state.tableData);
    },
    //更新用户数据
    [types.UPDATE_USER_DATA](state, {
        newUser,
        updateIndex
    }) {
        // console.log(state.tableData, newUser, updateIndex，state.tableData[updateIndex]);
        Object.assign(state.tableData[updateIndex], newUser);
        // console.log(state.tableData[updateIndex]);
    },
    //清空筛查条件
    [types.CLEAN_SELECT_DATA](state) {
        state.selectData = {
            name: '',
            address: [],
            age: '',
            phone: ''
        };
        state.selectOptions = {};
    },
    //设置筛查信息
    [types.SET_SELECT_OPTIONS](state, {
        selectOptions
    }) {
        state.selectOptions = selectOptions;
    },
    //设置页码
    [types.SET_PAGE_INDEX](state, {
        currentPage
    }) {
        state.currentPage = currentPage;
    }
};